Computer graphics systems are commonly used for displaying graphical representations of objects on a two-dimensional video display screen. Current computer graphics systems provide highly detailed representations and are used in a variety of applications.
In typical computer graphics systems, an object to be represented on the display screen is broken down into graphics primitives. Primitives are basic components of a graphics display and may include points, lines, vectors, and polygons, such as triangles and quadrilaterals. Typically, a combined hardware and software system is implemented to render, or draw, the graphics primitives that represent a view of one or more objects being represented on the display screen.
The primitives of a three dimensional (3-D) object to be rendered are defined by a host computer in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitive in terms of the X, Y and Z coordinates of its vertices, as well as in terms of the red, green and blue (R, G and B) color values of each vertex. Additional primitive data may be used in specific applications. Rendering hardware interpolates the primitive data to compute the display screen pixels that represent each primitive and the R, G, and B color values for each pixel.
The basic components of a computer graphics system generally include a geometry engine, or geometry accelerator, a rasterizer, and a frame buffer. The system may also include texture mapping hardware. The geometry accelerator receives from the host computer primitive data that defines the primitives that make up the view to be displayed. The geometry accelerator performs transformations on the primitive data, such as decomposing quadrilaterals into triangles, and performs lighting, clipping, and plane equation calculations for each primitive. The output of the geometry accelerator is rendering data used by the rasterizer and the texture mapping hardware to generate final coordinate and color data for each pixel in each primitive. The pixel data from the rasterizer and, if available, the pixel data from the texture mapping hardware are combined and stored in the frame buffer for display on the video display screen.
In regard to the lighting calculations that are performed by the geometry accelerator, red, green, and blue color values are determined for each vertex by summing the ambient color and the diffuse and specular color contribution for each of the active light sources in the scene. A scene may have several light sources of different types.
The operations of the geometry accelerator are highly computation intensive. One frame of a graphics display may include thousands of primitives. To achieve state of the art performance, the geometry accelerator may be required to perform on the order of several hundred million floating point (fp) calculations per second. Furthermore, the volume of data transferred between the host computer and the graphics hardware is very large. The data for a single quadrilateral may be on the order of 64 words, each word being 32 bits. Additional data transmitted from the host computer to the geometry accelerator includes lighting parameters, clipping parameters, and any other parameters needed to generate the graphics display.
Various techniques have been employed to improve the performance of geometry accelerators, including pipelining and multiprocessing. Nonetheless, a need continues in the industry for additional improvements that will increase performance.
Several problems arise when the lighting calculations are performed in hardware in geometry accelerators. One problem involves clamping the fp results of the lighting equations to a value between 0 and 1, inclusive. The results must be clamped to within this range so that no overflow occurs downstream of the geometry accelerator. Overflow can occur because the hardware that is downstream of the accelerator generally utilizes fixed precision arithmetic. Another problem that arises with performing lighting calculations with hardware involves taking the absolute value of a result. These and other problems are addressed and solved herein by the present invention.